home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2004 March / PCWMAR04.iso / Software / Trial / TestTrack Pro 6 / ttprowininstall.exe / %LSMAINDIR% / LicenseServer Help / wwhelp / wwhimpl / common / scripts / controls.js < prev    next >
Encoding:
JavaScript  |  2003-12-12  |  12.7 KB  |  451 lines

  1. // Copyright (c) 2000-2001 Quadralay Corporation.  All rights reserved.
  2. //
  3.  
  4. function  WWHControls_Object()
  5. {
  6.   this.mSyncPrevNext  = new Array(null, null, null);
  7.  
  8.   this.fSansNavigation = WWHControls_SansNavigation;
  9.   this.fLeftHTML       = WWHControls_LeftHTML;
  10.   this.fRightHTML      = WWHControls_RightHTML;
  11.   this.fUpdateHREF     = WWHControls_UpdateHREF;
  12.   this.fSyncTOC        = WWHControls_SyncTOC;
  13.   this.fPrevious       = WWHControls_Previous;
  14.   this.fNext           = WWHControls_Next;
  15.   this.fRelatedTopics  = WWHControls_RelatedTopics;
  16.   this.fEmail          = WWHControls_Email;
  17.   this.fPrint          = WWHControls_Print;
  18.   this.fBookmark       = WWHControls_Bookmark;
  19.   this.fBookmarkData   = WWHControls_BookmarkData;
  20.   this.fBookmarkLink   = WWHControls_BookmarkLink;
  21. }
  22.  
  23. function  WWHControls_SansNavigation()
  24. {
  25.   var  bSansNavigation = false;
  26.  
  27.  
  28.   if (typeof WWHFrame.WWHNavigationFrame == "undefined")
  29.   {
  30.     bSansNavigation = true;
  31.   }
  32.  
  33.   return bSansNavigation;
  34. }
  35.  
  36. function  WWHControls_LeftHTML()
  37. {
  38.   var  HTML = "";
  39.   var  Settings = WWHFrame.WWHHelp.mSettings;
  40.  
  41.  
  42.   HTML += "<table border=\"0\">\n";
  43.   HTML += " <tr>\n";
  44.  
  45.   // Display controls
  46.   //
  47.   if (this.fSansNavigation())
  48.   {
  49.     HTML += "  <td width=\"23\">\n";
  50.     HTML += "   <a href=\"javascript:WWHFrame.WWHControls.fSyncTOC();\">\n";
  51.     HTML += "    <img name=\"WWHFrameSetIcon\" alt=\"" + WWHFrame.WWHHelp.mMessages.mShowNavigationIconLabel + "\" border=\"0\" src=\"../images/frameset.gif\" width=\"23\" height=\"21\">\n";
  52.     HTML += "   </a>\n";
  53.     HTML += "  </td>\n";
  54.   }
  55.   else if (Settings.mbSyncContentsEnabled)
  56.   {
  57.     HTML += "  <td width=\"23\">\n";
  58.     HTML += "   <a href=\"javascript:WWHFrame.WWHControls.fSyncTOC();\">\n";
  59.     HTML += "    <img name=\"WWHSyncIcon\" alt=\"" + WWHFrame.WWHHelp.mMessages.mSyncIconLabel + "\" border=\"0\" src=\"../images/syncx.gif\" width=\"23\" height=\"21\">\n";
  60.     HTML += "   </a>\n";
  61.     HTML += "  </td>\n";
  62.   }
  63.  
  64.   if (Settings.mbPrevEnabled)
  65.   {
  66.     HTML += "  <td width=\"23\">\n";
  67.     HTML += "   <a href=\"javascript:WWHFrame.WWHControls.fPrevious();\">\n";
  68.     HTML += "    <img name=\"WWHPrevIcon\" alt=\"" + WWHFrame.WWHHelp.mMessages.mPrevIconLabel + "\" border=\"0\" src=\"../images/prevx.gif\" width=\"23\" height=\"21\">\n";
  69.     HTML += "   </a>\n";
  70.     HTML += "  </td>\n";
  71.   }
  72.  
  73.   if (Settings.mbNextEnabled)
  74.   {
  75.     HTML += "  <td width=\"23\">\n";
  76.     HTML += "   <a href=\"javascript:WWHFrame.WWHControls.fNext();\">\n";
  77.     HTML += "    <img name=\"WWHNextIcon\" alt=\"" + WWHFrame.WWHHelp.mMessages.mNextIconLabel + "\" border=\"0\" src=\"../images/nextx.gif\" width=\"23\" height=\"21\">\n";
  78.     HTML += "   </a>\n";
  79.     HTML += "  </td>\n";
  80.   }
  81.  
  82.   HTML += " </tr>\n";
  83.   HTML += "</table>\n";
  84.  
  85.   return HTML;
  86. }
  87.  
  88. function  WWHControls_RightHTML()
  89. {
  90.   var  HTML = "";
  91.   var  Settings = WWHFrame.WWHHelp.mSettings;
  92.  
  93.  
  94.   // Confirm controls can be displayed
  95.   //
  96.   if (Settings.mbEmailEnabled)
  97.   {
  98.     Settings.mbEmailEnabled = ((typeof Settings.mEmailAddress == "string") &&
  99.                                (Settings.mEmailAddress.length > 0));
  100.   }
  101.  
  102.   if (Settings.mbPrintEnabled)
  103.   {
  104.     Settings.mbPrintEnabled = ((typeof WWHFrame.WWHContentFrame.WWHDocumentFrame.focus != "undefined") &&
  105.                                (typeof WWHFrame.WWHContentFrame.WWHDocumentFrame.print != "undefined"))
  106.   }
  107.  
  108.  
  109.   // Display controls
  110.   //
  111.   HTML += "<table border=\"0\">\n";
  112.   HTML += " <tr>\n";
  113.  
  114.  if (Settings.mbEmailEnabled)
  115.   {
  116.     HTML += "  <td width=\"0\">\n";
  117. //    HTML += "   <a href=\"javascript:WWHFrame.WWHControls.fEmail();\">\n";
  118.     HTML += "    <img name=\"WWHEmailIcon\" alt=\"" + WWHFrame.WWHHelp.mMessages.mEmailIconLabel + "\" border=\"0\" src=\"../images/emailx.gif\" width=\"1\" height=\"1\">\n";
  119. //    HTML += "   </a>\n";
  120.     HTML += "  </td>\n";
  121.   }
  122.  
  123.   if (Settings.mbRelatedTopicsEnabled)
  124.   {
  125.     HTML += "  <td width=\"23\">\n";
  126.     HTML += "   <a href=\"javascript:WWHFrame.WWHControls.fRelatedTopics();\">\n";
  127.     HTML += "    <img name=\"WWHRelatedTopicsIcon\" alt=\"" + WWHFrame.WWHHelp.mMessages.mRelatedTopicsIconLabel + "\" border=\"0\" src=\"../images/relatedx.gif\" width=\"23\" height=\"21\">\n";
  128.     HTML += "   </a>\n";
  129.     HTML += "  </td>\n";
  130.   }
  131.  
  132.  //if (Settings.mbEmailEnabled)
  133.  // {
  134.  //   HTML += "  <td width=\"23\">\n";
  135.  //   HTML += "   <a href=\"javascript:WWHFrame.WWHControls.fEmail();\">\n";
  136.  //   HTML += "    <img name=\"WWHEmailIcon\" alt=\"" + WWHFrame.WWHHelp.mMessages.mEmailIconLabel + "\" border=\"0\" src=\"../images/emailx.gif\" width=\"23\" height=\"21\">\n";
  137.  //   HTML += "   </a>\n";
  138.  //   HTML += "  </td>\n";
  139.  // }
  140.  
  141.   if (Settings.mbPrintEnabled)
  142.   {
  143.     HTML += "  <td width=\"23\">\n";
  144.     HTML += "   <a href=\"javascript:WWHFrame.WWHControls.fPrint();\">\n";
  145.     HTML += "    <img name=\"WWHPrintIcon\" alt=\"" + WWHFrame.WWHHelp.mMessages.mPrintIconLabel + "\" border=\"0\" src=\"../images/printx.gif\" width=\"23\" height=\"21\">\n";
  146.     HTML += "   </a>\n";
  147.     HTML += "  </td>\n";
  148.   }
  149.  
  150.   if (Settings.mbBookmarkEnabled)
  151.   {
  152.     HTML += "  <td width=\"0\">\n";
  153.    // HTML += "   <a href=\"javascript:WWHFrame.WWHControls.fBookmark();\">\n";
  154.     HTML += "    <img name=\"WWHBookmarkIcon\" alt=\"" + WWHFrame.WWHHelp.mMessages.mBookmarkIconLabel + "\" border=\"0\" src=\"../images/bkmarkx.gif\" width=\"1\" height=\"1\">\n";
  155.  //   HTML += "   </a>\n";
  156.     HTML += "  </td>\n";
  157.   }
  158.  
  159.   HTML += " </tr>\n";
  160.   HTML += "</table>\n";
  161.  
  162.   return HTML;
  163. }
  164.  
  165. function  WWHControls_UpdateHREF(ParamHREF)
  166. {
  167.   var  DocumentBookmark = "";
  168.   var  ControlsDocument;
  169.   var  Settings = WWHFrame.WWHHelp.mSettings;
  170.   var  Prefix = WWHFrame.WWHHelp.mHelpURLPrefix;
  171.   var  IconURL;
  172.  
  173.  
  174.   // Update sync/prev/next array
  175.   //
  176.   this.mSyncPrevNext = WWHFrame.WWHHelp.fGetSyncPrevNext(ParamHREF);
  177.  
  178.   // Process left control frame
  179.   //
  180.   ControlsDocument = eval("WWHFrame.WWHContentFrame.WWHPageNavFrame.WWHControlsLeftFrame.document");
  181.  
  182.   // Set Sync Icon
  183.   //
  184.   if (this.fSansNavigation())
  185.   {
  186.     ;  // Nothing to do
  187.   }
  188.   else if (Settings.mbSyncContentsEnabled)
  189.   {
  190.     if (this.mSyncPrevNext[0] != null)
  191.     {
  192.       IconURL =  Prefix + "wwhelp/wwhimpl/common/images/sync.gif";
  193.     }
  194.     else
  195.     {
  196.       IconURL = Prefix + "wwhelp/wwhimpl/common/images/syncx.gif";
  197.     }
  198.     ControlsDocument.images["WWHSyncIcon"].src = IconURL;
  199.   }
  200.  
  201.   // Set Previous Icon
  202.   //
  203.   if (Settings.mbPrevEnabled)
  204.   {
  205.     if (this.mSyncPrevNext[1] != null)
  206.     {
  207.       IconURL = Prefix + "wwhelp/wwhimpl/common/images/prev.gif";
  208.     }
  209.     else
  210.     {
  211.       IconURL = Prefix + "wwhelp/wwhimpl/common/images/prevx.gif";
  212.     }
  213.     ControlsDocument.images["WWHPrevIcon"].src = IconURL;
  214.   }
  215.  
  216.   // Set Next Icon
  217.   //
  218.   if (Settings.mbNextEnabled)
  219.   {
  220.     if (this.mSyncPrevNext[2] != null)
  221.     {
  222.       IconURL = Prefix + "wwhelp/wwhimpl/common/images/next.gif";
  223.     }
  224.     else
  225.     {
  226.       IconURL = Prefix + "wwhelp/wwhimpl/common/images/nextx.gif";
  227.     }
  228.     ControlsDocument.images["WWHNextIcon"].src = IconURL;
  229.   }
  230.  
  231.   // Process right control frame
  232.   //
  233.   ControlsDocument = eval("WWHFrame.WWHContentFrame.WWHPageNavFrame.WWHControlsRightFrame.document");
  234.  
  235.   // Set Related Topics Icon
  236.   //
  237.   if (Settings.mbRelatedTopicsEnabled)
  238.   {
  239.     if (typeof WWHFrame.WWHContentFrame.WWHDocumentFrame.WWHDefineRelatedTopics == "function")
  240.     {
  241.       IconURL = Prefix + "wwhelp/wwhimpl/common/images/related.gif";
  242.     }
  243.     else
  244.     {
  245.       IconURL = Prefix + "wwhelp/wwhimpl/common/images/relatedx.gif";
  246.     }
  247.     ControlsDocument.images["WWHRelatedTopicsIcon"].src = IconURL;
  248.   }
  249.  
  250.   // Set E-Mail Icon
  251.   //
  252.   if (Settings.mbEmailEnabled)
  253.   {
  254.     if (this.mSyncPrevNext[0] != null)
  255.     {
  256.       IconURL = Prefix + "wwhelp/wwhimpl/common/images/email.gif";
  257.     }
  258.     else
  259.     {
  260.       IconURL = Prefix + "wwhelp/wwhimpl/common/images/emailx.gif";
  261.     }
  262.     ControlsDocument.images["WWHEmailIcon"].src = IconURL;
  263.   }
  264.  
  265.   // Set Print Icon
  266.   //
  267.   if (Settings.mbPrintEnabled)
  268.   {
  269.     if (this.mSyncPrevNext[0] != null)
  270.     {
  271.       IconURL = Prefix + "wwhelp/wwhimpl/common/images/print.gif";
  272.     }
  273.     else
  274.     {
  275.       IconURL = Prefix + "wwhelp/wwhimpl/common/images/printx.gif";
  276.     }
  277.     ControlsDocument.images["WWHPrintIcon"].src = IconURL;
  278.   }
  279.  
  280.   // Set Bookmark Icon
  281.   //
  282.   if (Settings.mbBookmarkEnabled)
  283.   {
  284.     if (this.mSyncPrevNext[0] != null)
  285.     {
  286.       IconURL = Prefix + "wwhelp/wwhimpl/common/images/bkmark.gif";
  287.     }
  288.     else
  289.     {
  290.       IconURL = Prefix + "wwhelp/wwhimpl/common/images/bkmarkx.gif";
  291.     }
  292.     ControlsDocument.images["WWHBookmarkIcon"].src = IconURL;
  293.   }
  294. }
  295.  
  296. function  WWHControls_SyncTOC()
  297. {
  298.   var  URL = WWHStringUtilities_NormalizeURL(WWHFrame.WWHContentFrame.WWHDocumentFrame.location.href);
  299.  
  300.  
  301.   // Show navigation or reveal in TOC?
  302.   //
  303.   if (this.fSansNavigation())
  304.   {
  305.     WWHFrame.WWHHandler.fSyncTOC(URL);
  306.   }
  307.   else
  308.   {
  309.     if (this.mSyncPrevNext[0] != null)
  310.     {
  311.       WWHFrame.WWHHandler.fSyncTOC(URL);
  312.     }
  313.   }
  314. }
  315.  
  316. function  WWHControls_Previous()
  317. {
  318.   if (this.mSyncPrevNext[1] != null)
  319.   {
  320.     WWHFrame.WWHHelp.fSetDocumentHREF(this.mSyncPrevNext[1], false);
  321.   }
  322. }
  323.  
  324. function  WWHControls_Next()
  325. {
  326.   if (this.mSyncPrevNext[2] != null)
  327.   {
  328.     WWHFrame.WWHHelp.fSetDocumentHREF(this.mSyncPrevNext[2], false);
  329.   }
  330. }
  331.  
  332. function  WWHControls_RelatedTopics()
  333. {
  334.   if (typeof WWHFrame.WWHContentFrame.WWHDocumentFrame.WWHDefineRelatedTopics == "function")
  335.   {
  336.     WWHFrame.WWHRelatedTopics.fShow();
  337.   }
  338. }
  339.  
  340. function  WWHControls_Email()
  341. {
  342.   if (this.mSyncPrevNext[0] != null)
  343.   {
  344.     WWHFrame.WWHContentFrame.WWHDocumentFrame.location = "mailto:" + WWHFrame.WWHHelp.mSettings.mEmailAddress + "?subject=Feedback: " + escape(this.mSyncPrevNext[0]);
  345.   }
  346. }
  347.  
  348. function  WWHControls_Print()
  349. {
  350.   if (this.mSyncPrevNext[0] != null)
  351.   {
  352.     WWHFrame.WWHContentFrame.WWHDocumentFrame.focus();
  353.     WWHFrame.WWHContentFrame.WWHDocumentFrame.print();
  354.   }
  355. }
  356.  
  357. function  WWHControls_Bookmark()
  358. {
  359.   if (this.mSyncPrevNext[0] != null)
  360.   {
  361.     var  BookmarkData;
  362.  
  363.  
  364.     BookmarkData = this.fBookmarkData();
  365.     if ((BookmarkData[0] != null) &&
  366.         (BookmarkData[1] != null))
  367.     {
  368.       if ((WWHFrame.WWHBrowserInfo.mBrowser == 2) &&  // Shorthand for IE
  369.           ( ! WWHFrame.WWHBrowserInfo.mbMacIE45))
  370.       {
  371.         window.external.AddFavorite(BookmarkData[1], BookmarkData[0]);
  372.       }
  373.       else
  374.       {
  375.         var  Window;
  376.  
  377.  
  378.         Window = window.open(WWHFrame.WWHHelp.mHelpURLPrefix + "wwhelp/wwhimpl/common/html/bookmark.htm", "WWHBookmarkLinkWindow", "width=400,height=20");
  379.         Window.document.open();
  380.         Window.document.writeln("<p>" + WWHFrame.WWHHelp.mMessages.mBookmarkLinkMessage + "</p>");
  381.         Window.document.writeln("<p>" + this.fBookmarkLink() + "</p>");
  382.         Window.document.close();
  383.       }
  384.     }
  385.   }
  386. }
  387.  
  388. function  WWHControls_BookmarkData()
  389. {
  390.   var  BookmarkData = new Array(null, null);
  391.  
  392.  
  393.   if (this.mSyncPrevNext[0] != null)
  394.   {
  395.     var  DocumentURL;
  396.  
  397.  
  398.     // Determine bookmark link
  399.     //
  400.     DocumentURL = WWHFrame.WWHHelp.fGetBookFileHREF(this.mSyncPrevNext[0]);
  401.     if (DocumentURL != null)
  402.     {
  403.       var  DocumentTitle;
  404.       var  ResetEverything;
  405.       var  DocumentBookmarkURL;
  406.  
  407.  
  408.       DocumentTitle = WWHFrame.WWHHelp.fHREFToTitle(this.mSyncPrevNext[0]);
  409.  
  410.       if ((WWHFrame.WWHBrowserInfo.mBrowser == 1) ||  // Shorthand for Netscape
  411.           (WWHFrame.WWHBrowserInfo.mBrowser == 4))    // Shorthand for Netscape 6.0
  412.       {
  413.         ResetEverything = "y=eval("document.open();document.writeln('<a href=\\""+x+"\\">"+x+"</a>');document.close();")";
  414.       }
  415.       else
  416.       {
  417.         ResetEverything = "location=x";
  418.       }
  419.  
  420.       DocumentBookmarkURL = WWHFrame.WWHHelp.mHelpURLPrefix + "wwhelp/wwhimpl/common/html/wwhelp.htm?href=" + WWHStringUtilities_RestoreEscapedSpaces(DocumentURL);
  421.       if (this.fSansNavigation())
  422.       {
  423.         DocumentBookmarkURL += "&single=true"
  424.       }
  425.       DocumentBookmarkURL = "javascript:x=unescape('" + escape(DocumentBookmarkURL) + "');if(typeof window.WWHFrame!='undefined'){window.WWHFrame.WWHHelp.fSetContextDocument(x);}else{" + ResetEverything + ";}";
  426.  
  427.       // Set bookmark data
  428.       //
  429.       BookmarkData[0] = DocumentTitle;
  430.       BookmarkData[1] = DocumentBookmarkURL;
  431.     }
  432.   }
  433.  
  434.   return BookmarkData;
  435. }
  436.  
  437. function  WWHControls_BookmarkLink()
  438. {
  439.   var  BookmarkLink = "";
  440.   var  BookmarkData = this.fBookmarkData();
  441.  
  442.  
  443.   if ((BookmarkData[0] != null) &&
  444.       (BookmarkData[1] != null))
  445.   {
  446.     BookmarkLink = "<a href=\"" + BookmarkData[1] + "\">" + BookmarkData[0] + "</a>";
  447.   }
  448.  
  449.   return BookmarkLink;
  450. }
  451.